package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.InstitutionRepository;
import org.example.petitionplatformsystem.dao.model.Institution;
import org.example.petitionplatformsystem.service.InstitutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InstitutionServiceImpl implements InstitutionService {
    @Autowired
    private InstitutionRepository institutionRepository;

    @Override
    public Institution AddInstitution(Institution institution) {
        return institutionRepository.save(institution);
    }

    @Override
    public void DeleteInstitution(Long InstitutionId) {
        institutionRepository.deleteById(InstitutionId);
    }

    @Override
    public Institution UpdateInstitution(Institution institution) {
        return institutionRepository.save(institution);
    }

    @Override
    public List<Institution> GetAllInstitution() {
        return institutionRepository.findAll();
    }

    @Override
    public Institution getInstitutionById(Long InstitutionId) {
        return institutionRepository.findById(InstitutionId)
                .orElse(null);
    }
}
